Channel: Automation Step by Step
Category: Education
Tags: karate api testing tutorial for beginnersapi automation testing using karatekarate framework for api testingkarate api testing tutorialkarate automation testing by raghav pal
Description: FREE Tutorials - automationstepbystep.com Why we need command line DEMO Options - JUnit4 JUnit5 Why do we need command line execution: Easy and fast Less memory consuming Options Integration with 3rd Party apps/processes CI-CD Step 1 - Check Maven is setup on your system mvn -version Step 2 - If Not, setup maven | Download | Set env variables maven.apache.org/download.cgi Step 3 - Open CMD and CD to the location of project folder Step 4 - Run command mvn clean install mvn clean Cleans the project | deletes target folder will delete all previously compiled Java .class files and resources (like .properties) in your project mvn install Builds the project as described in pom.xml and installs the project files (JAR, WAR, pom.xml, etc) to the local repository mvn test Invokes the testRunner file runs test classes that follow the *Test.java naming conventions by default JUnit4 Step 1 - Create an empty class (TestRunner) in the same package as your feature files import com.intuit.karate.junit4.Karate; import org.junit.runner.RunWith; @RunWith(Karate.class) public class CatsRunner { } The name of the class doesn’t matter It will automatically run all the *.feature files in the same package Step 2 - Rt click and Select ‘Run as JUnit Test’ Karate will traverse sub-directories and look for *.feature files and run them Step 3 - Open command line > Goto project folder Step 4 - Run commands mvn clean install mvn test JUnit5 Step 1 - Create a class in the same package as your feature files The name of the class doesn’t matter class SampleTest { } Step 2 - Here we can create functions to run features by name, by tags etc @Karate.Test Karate testSample() { return Karate.run("sample").relativeTo(getClass()); } @Karate.Test Karate testTags() { return Karate.run("tags").tags("@second").relativeTo(getClass()); } Only one import is needed import com.intuit.karate.junit5.Karate; With this you can now Rt click on single methods and run In case you do not find Run as JUnit Add the following in pom.xml Rt click on pom.xml > Maven > Update Step 3 - To enable running from command line, Add the latest version of the maven-surefire-plugin in pom.xml Step 4 - Open command line > Goto project folder Step 5 - Run commands mvn test -Dtest=SampleTest#testTags #karateapiautomationtesting Join Automation Step By Step channel: youtube.com/automationstepbystep/join Stories by Raghav - automationstepbystep.com/stories My Udemy Courses - automationstepbystep.com/udemy-discounts GitHub - github.com/Raghav-Pal Udemy - udemy.com/user/raghav-pal-3 Training by Raghav at your venue - raghav.qna@gmail.com Training schedule - automationstepbystep.com/trainings-2 Tutorials Library - automationstepbystep.com/free-online-tutorials UI TESTING API TESTING PERFORMANCE TESTING CI CD DEVOPS MOBILE TESTING CLOUD SERVICES PROGRAMMING VERSION CONTROL SYSTEMS BUILD TOOLS Ask Raghav - bit.ly/2CoJGWf MOCK Interviews - bit.ly/3JT9mrx All Playlists - bit.ly/2LSiezA Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you You can support my mission for education by sharing this knowledge and helping as many people as you can If my work has helped you, consider helping any animal near you, in any way you can. Never Stop Learning Raghav